[ISSUE #10666][BUG] Persist commitLog truncate marker - #10816
Conversation
Signed-off-by: chenxu80 <chenxu80@meituan.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #10816 +/- ##
=============================================
+ Coverage 48.26% 48.29% +0.02%
- Complexity 13437 13514 +77
=============================================
Files 1377 1380 +3
Lines 100840 101184 +344
Branches 13035 13129 +94
=============================================
+ Hits 48670 48864 +194
- Misses 46223 46321 +98
- Partials 5947 5999 +52 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR persists an invalid CommitLog header at the truncation boundary before truncating dirty files, preventing stale records from being recovered after an HA slave restart. The implementation is well-structured with proper boundary validation, file hold/release lifecycle, and comprehensive test coverage.
Findings
- [Info]
CommitLog.java:920— ThevalidateTruncateMarkerPositionmethod is thorough but adds an extra MappedFile lookup. Consider whether this could be combined with the initialfindMappedFileByOffsetcall to reduce I/O on the hot truncation path. - [Info]
DefaultMessageStoreTest.java— Good test coverage across normal recovery, abnormal recovery, first-message boundary, and non-boundary rejection scenarios.
Suggestions
The overall approach is sound. One minor consideration: the persistTruncateMarker method throws IllegalStateException for all error cases — differentiating error types (e.g., a custom TruncationException) could help callers distinguish between recoverable and unrecoverable failures, though this is optional.
LGTM.
Automated review by github-manager-bot
🤖 Automated Review by RockteMQ-AIReview of the diff for Overall: The change correctly adds a durable invalid header at the truncation boundary so that recovery stops exactly there instead of rolling forward into stale data. The failure-path handling that keeps Findings🟡 Warning —
🟡 Warning — The bounds check 🟡 Warning — Boundary validation accepts only 🟢 Suggestion — Consider asserting 🟢 Suggestion — Add a test that truncates exactly at a mapped-file boundary (e.g., at 🟢 Suggestion — The catch clause handles Correctness highlights
No critical correctness issues were found. This is an automated review. Please verify findings before acting on them. |
Which Issue(s) This PR Fixes
Fixes #10666
Brief Description
Persist an invalid CommitLog header at the truncation boundary before
truncating dirty files.
The marker is forced to disk so stale CommitLog records after the consistent
offset cannot be recovered after an HA slave restarts.
This change also:
ReputMessageServicestopped when truncation fails;How Did You Test This Change?
bazel test //store:src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest --test_output=errorsmvn -o -pl store -am testmvn -o -pl store -am -DskipTests package